//
//  XYPreViewController.m
//  XYRTCEngineDemo
//
//  Created by 高超 on 2021/8/3.
//

#import "XYPreViewController.h"
#import "XYProcessViewController.h"

@interface XYPreViewController ()

@end

@implementation XYPreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"xylink_demo";

    [self initSubviews];
}

- (void)initSubviews {
    NSArray *buttonTitleArray = @[@"初始化",@"小鱼账号登录",@"三方账号登录",@"加入会议",@"退出登录"];
    for (NSInteger i = 0; i < 5; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button.frame = CGRectMake(50, 200+80*i, kScreen.width-100, 50);
        button.layer.cornerRadius = 5.f;
        button.layer.borderColor = XYColor(@"#393946", 0.6).CGColor;
        button.layer.borderWidth = 1.f;
        [button setTitle:buttonTitleArray[i] forState:UIControlStateNormal];
        [button setTitleColor:XYColor(@"#393946", 0.9) forState:UIControlStateNormal];
        button.tag = i+1;
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
    }
}

- (void)buttonClick:(UIButton *)sender {
    NSLog(@"%s : %ld", __FUNCTION__, sender.tag);
    if (sender.tag < 5) {
        XYProcessViewController *processVC = [[XYProcessViewController alloc] init];
        processVC.processType = sender.tag;
        [self.navigationController pushViewController:processVC animated:YES];
    } else {
        [[XYSDKManager share] logout];
    }
}


@end
